package shapes.shapes2D.distribution.goldenRatio 
{
	import flash.display.Graphics;
	import flash.geom.Rectangle;
	/**
	 * ...
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class GoldenRatio
	{
		
		static public const RATIO:Number = ( ( 1 + Math.sqrt( 5 ) ) * .5 );
		
		public function GoldenRatio() 
		{
		}
		
		static public function fibonacci( n:Number ):Number
		{
			if ( n == 0 ) return 0;
			
			if ( n == 1 ) return 1;
			
			if ( n >= 2 ) return fibonacci(n - 1) + fibonacci(n - 2);
			
			return 0;
		}
		/**
		 * Returns two proportional numbers whose sum is n.
		 * @param	n
		 * @param	f
		 * @return
		 */
		static public function complements( n:Number, f:Number = 4 ):Array
		{
		
			f = Math.max( 1, Math.min( f, 10 ) );
			
			n /= fibonacci( f + 2 );
			
			return [ n * fibonacci( f + 1 ) , n * fibonacci( f ) ];
			
		}
		
		static public function goldenStripes( graphics:Graphics, rect:Rectangle, count:int = 10 ):void
		{
			var x:int = 0, y:int = 0;
			var w:int = 256, h:int = 256;
			
			//th = h// # top height
			//bh = 0// # bottom height
			//for i in range(count):
				//th, bh = goldenratio(th)
				//v = float(th)/w + 0.3
				//fill(0, v/2, v)
				//rect(x, y, w, th)
				//y += th
				//th = bh
		}
		
	}
}